<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div id="app"></div>
    <template id="pengfan">
      <!-- :style = {cssPropertyName: csspropertyValue} -->
      <div :style="{color: finalColor,'font-size': '20px'}">哈哈哈</div>
      <div :style="{color: finalColor,fontSize: '20px'}">哈哈哈</div>
      <div :style="{color: finalColor,fontSize:finalSize +'px'}">哈哈哈</div>
      <!-- 绑定一个data中的属性值，并且是一个对象 -->
      <div :style="finalStyleObj">哈哈哈</div>
      <!-- 调用一个方法 -->
      <div :style="getFinalStyleObj()">哈哈哈</div>
    </template>
    <script src="../js/vue.js"></script>
    <script>
      Vue.createApp({
        template: "#pengfan",
        data() {
          return {
            message: "Hello World",
            finalColor: "green",
            finalSize: 50,
            finalStyleObj: {
              fontSize: "100px",
              fontWeight: 700,
              backgroundColor: "red",
            },
          };
        },
        methods: {
          getFinalStyleObj() {
            return this.finalStyleObj
          }
        },
      }).mount("#app");
    </script>
  </body>
</html>
